import Vue from "vue";
import VueRouter from "vue-router";
import { createRouter, createWebHashHistory } from "vue-router";
// 引入自己写的layout
import Layout from "@/layout";
Vue.use(VueRouter);

const routes = [
    {
        path: "/login",
        name: "login",
        component: () => import("@/views/Login"),
    },
    {
        path: "/", //根目录路由为/
        component: Layout, //指定使用Layout组件布局
        redirect: "/home", //重定向至/home页面
        children: [
            {
                //子菜单信息
                path: "/home", //路径
                name: "home",
                component: () => import("@/views/Home"), //指定组件
                meta: { title: "消息中心", access: 0, affix: true },
            },
        ],
    },
    {
        path: "/",
        component: Layout,
        children: [
            {
                // 消息中心
                path: "/msgCenterResource/message/index",
                name: "Message",
                component: () => import("../views/message/Index"),
                meta: { title: "消息中心", access: 0, affix: true },
            },
            {
                // 消息中心
                path: "/msgCenterResource/record/eventRecordList",
                name: "EventRecordList",
                component: () => import("../views/message/EventRecordList"),
                meta: { title: "消息中心", access: 0, affix: true },
            },
            {
                // 消息中心-事件记录
                path: "/msgCenterResource/record/eventRecord",
                name: "EventRecord",
                component: () => import("../views/message/EventRecord"),
                meta: { title: "事件记录", access: 0, affix: true },
            },
            {
                // 消息中心-告警记录
                path: "/msgCenterResource/record/alarmRecord",
                name: "AlarmRecord",
                component: () => import("../views/message/AlarmRecord"),
                meta: { title: "告警记录", access: 0, affix: true },
            },
            {
                // 消息中心-提醒记录
                path: "/msgCenterResource/record/remindRecord",
                name: "RemindRecord",
                component: () => import("../views/message/RemindRecord"),
                meta: { title: "提醒记录", access: 0, affix: true },
            },
            {
                // 消息中心-通知记录
                path: "/msgCenterResource/record/noticeRecord",
                name: "NoticeRecord",
                component: () => import("../views/message/NoticeRecord"),
                meta: { title: "通知记录", access: 0, affix: true },
            },
            {
                // 消息中心-消息统计
                path: "/msgCenterResource/record/statistics",
                name: "Statistics",
                component: () => import("../views/message/statistics"),
                meta: { title: "消息统计", access: 0, affix: true },
            },
            {
                // 消息中心-告警分类
                path: "/msgCenterResource/baseSetting/alarmClassify",
                name: "AlarmClassify",
                component: () => import("../views/message/AlarmClassify"),
                meta: { title: "告警分类", access: 0, affix: true },
            },
            {
                // 消息中心-告警设置
                path: "/msgCenterResource/baseSetting/alarmSetting",
                name: "AlarmSetting",
                component: () => import("../views/message/AlarmSetting"),
                meta: { title: "告警设置", access: 0, affix: true },
            },
            {
                // 消息中心-通知模板
                path: "/msgCenterResource/baseSetting/noticeTemplate",
                name: "NoticeTemplate",
                component: () => import("../views/message/NoticeTemplate"),
                meta: { title: "通知模板", access: 0, affix: true },
            },
            {
                // 消息中心-事件分类
                path: "/msgCenterResource/baseSetting/eventClassify",
                name: "EventClassify",
                component: () => import("../views/message/EventClassify"),
                meta: { title: "事件分类", access: 0, affix: true },
            },
            {
                // 消息中心-阀值设置
                path: "/msgCenterResource/msgSetting/thresholdSetting",
                name: "ThresholdSetting",
                component: () => import("../views/message/ThresholdSetting"),
                meta: { title: "阀值设置", access: 0, affix: true },
            },
            {
                // 消息中心-联动控制记录
                path: "/msgCenterResource/record/controlRecords",
                name: "Controlrecords",
                component: () => import("../views/message/Controlrecords"),
                meta: { title: "联动控制记录", access: 0, affix: true },
            },
            {
                // 消息中心-事件定义
                path: "/msgCenterResource/msgSetting/monitorEvent",
                name: "Monitorevent",
                component: () => import("../views/message/Monitorevent"),
                meta: { title: "事件定义", access: 0, affix: true },
            },
            {
                // 消息中心-联动动作
                path: "/msgCenterResource/baseSetting/controlAction",
                name: "Controlaction",
                component: () => import("../views/message/Controlaction"),
                meta: { title: "联动动作", access: 0, affix: true },
            },
            {
                // 消息中心-定时任务
                path: "/msgCenterResource/msgSetting/scheduledTask",
                name: "Scheduledtask",
                component: () => import("../views/message/Scheduledtask"),
                meta: { title: "定时任务", access: 0, affix: true },
            },
            {
                // 消息中心-监听配置
                path: "/msgCenterResource/msgSetting/monitorSetting",
                name: "Monitorsetting",
                component: () => import("../views/message/Monitorsetting"),
                meta: { title: "监听配置", access: 0, affix: true },
            },
            {
                // 消息中心-事件通知
                path: "/msgCenterResource/msgSetting/eventinForm",
                name: "Eventinform",
                component: () => import("../views/message/Eventinform"),
                meta: { title: "事件通知", access: 0, affix: true },
            },
            {
                // 消息中心-事件告警
                path: "/msgCenterResource/msgSetting/eventalarm",
                name: "Eventalarm",
                component: () => import("../views/message/Eventalarm"),
                meta: { title: "事件告警", access: 0, affix: true },
            },
            {
                // 消息中心-设备组
                path: "/msgCenterResource/baseSetting/deviceGroup",
                name: "deviceGroup",
                component: () => import("../views/message/devicegroup"),
                meta: { title: "设备组", access: 0, affix: true },
            },
            ,
            {
                // 消息中心-控制设备明细（事件触发的子表）
                path: "/msgCenterResource/msgSetting/eventControl",
                name: "Eventcontrol",
                component: () => import("../views/message/Eventcontrol"),
                meta: {
                    title: "控制设备明细（事件触发的子表）",
                    access: 0,
                    affix: true,
                },
            },
        ],
    },
    {
        path: "/son",
        component: Layout,
        children: [
            {
                path: "/subSystemResource/son/entrance",
                name: "entrance",
                component: () => import("../views/son/entrance"),
                meta: { title: "门禁系统", access: 0, affix: true },
            },
            {
                path: "/subSystemResource/son/patrol",
                name: "patrol",
                component: () => import("../views/son/patrol"),
                meta: { title: "智能巡检", access: 0, affix: true },
            },
            {
                path: "/subSystemResource/son/stall",
                name: "stall",
                component: () => import("../views/son/stall"),
                meta: { title: "车位引导", access: 0, affix: true },
            },
            {
                path: "/subSystemResource/son/energy",
                name: "energy",
                component: () => import("../views/son/energy"),
                meta: { title: "能源管理", access: 0, affix: true },
            },
            {
                path: "/subSystemResource/son/visitors",
                name: "visitors",
                component: () => import("../views/son/visitors"),
                meta: { title: "访客通行", access: 0, affix: true },
            },
            {
                path: "/subSystemResource/son/BA",
                name: "BA",
                component: () => import("../views/son/BA"),
                meta: { title: "BA系统", access: 0, affix: true },
            },
            {
                path: "/subSystemResource/son/baKanban/index",
                name: "baKanban",
                component: () => import("../views/son/baKanban/index"),
                meta: { title: "BA看板", access: 0, affix: true },
            },
            {
                path: "/subSystemResource/son/elevator",
                name: "elevator",
                component: () => import("../views/son/elevator"),
                meta: { title: "梯控系统", access: 0, affix: true },
            },
            {
                path: "/subSystemResource/son/BD2",
                name: "BD2",
                component: () => import("../views/son/BD2"),
                meta: { title: "百度看板", access: 0, affix: true },
            },
            {
                path: "/subSystemResource/son/control",
                name: "control",
                component: () => import("../views/son/fireControl"),
                meta: { title: "消防控制", access: 0, affix: true },
            },
        ],
    },
    {
        path: "/iframe",
        component: Layout,
        children: [
            {
                path: "/iframe/testB",
                name: "testB",
                component: () => import("../views/iframe/testB"),
                meta: { title: "公共厕所", access: 0, affix: true },
            },
        ],
    },
    {
        path: "/monitoring",
        component: Layout,
        children: [
            {
                // 监控中心
                path: "/monitoring/toilet",
                name: "toilet",
                component: () => import("../views/monitoring/toilet"),
                meta: { title: "sid", access: 0, affix: true },
            },
            {
                path: "/monitoring/irrigate",
                name: "irrigate",
                component: () => import("../views/monitoring/irrigate"),
                meta: { title: "灌溉", access: 0, affix: true },
            },
            {
                path: "/monitoring/environment",
                name: "environment",
                component: () => import("../views/monitoring/environment"),
                meta: { title: "环境", access: 0, affix: true },
            },
            {
                path: "/monitoring/cockpit",
                name: "cockpit",
                component: () => import("../views/monitoring/cockpit"),
                meta: { title: "驾驶舱", access: 0, affix: true },
            },
            {
                path: "/monitoring/energy",
                name: "monitoringEnergy",
                component: () => import("../views/monitoring/energy"),
                meta: { title: "能耗", access: 0, affix: true },
            },
            {
                path: "/monitoring/parking",
                name: "parking",
                component: () => import("../views/monitoring/parking"),
                meta: { title: "停车场", access: 0, affix: true },
            },
            {
                path: "/monitoring/information",
                name: "information",
                component: () => import("../views/monitoring/information"),
                meta: { title: "信息发布", access: 0, affix: true },
            },
            {
                path: "/monitoring/illumination",
                name: "illumination",
                component: () => import("../views/monitoring/illumination"),
                meta: { title: "智慧照明", access: 0, affix: true },
            },
        ],
    },
    {
        path: "/canteen",
        component: Layout,
        children: [
            {
                path: "/canteen/toilet",
                name: "canteenToilet",
                component: () => import("../views/canteen/toilet"),
                meta: { title: "智慧厕所", access: 0 },
            },
            {
                path: "/canteen/broadcast",
                name: "broadcast",
                component: () => import("../views/canteen/broadcast"),
                meta: { title: "公共广播", access: 0 },
            },
            {
                path: "/canteen/video",
                name: "video",
                component: () => import("../views/canteen/video"),
                meta: { title: "视频监控", access: 0 },
            },
            {
                path: "/canteen/entrance",
                name: "canteenEntrance",
                component: () => import("../views/canteen/entrance"),
                meta: { title: "门禁", access: 0 },
            },
            {
                path: "/canteen/message",
                name: "message",
                component: () => import("../views/canteen/message"),
                meta: { title: "信息发布", access: 0 },
            },
            {
                path: "/canteen/kitchen",
                name: "kitchen",
                component: () => import("../views/canteen/kitchen"),
                meta: { title: "明厨亮照", access: 0 },
            },
        ],
    },
    //光伏
    {
        path: "/solarPower",
        component: Layout,
        children: [
            {
                path: "/subSystemResource/solarPower/overview/index",
                name: "overview",
                component: () => import("../views/solarPower/overview/index"),
                meta: { title: "光伏概览", access: 0 },
            },
            {
                path: "/subSystemResource/solarPower/plantDetails/index",
                name: "plantDetails",
                component: () =>
                    import("../views/solarPower/plantDetails/index"),
                meta: { title: "电站详情", access: 0 },
            },
            {
                path: "/subSystemResource/solarPower/deviceDetails/index",
                name: "deviceDetails",
                component: () =>
                    import("../views/solarPower/deviceDetails/index"),
                meta: { title: "设备详情", access: 0 },
            },
        ],
    },
    //场景
    {
        path: "/scene",
        component: Layout,
        children: [
            {
                path: "/subSystemResource/scene/officeRoom/index",
                name: "officeRoom",
                component: () => import("../views/scene/officeRoom/index"),
                meta: { title: "办公室", access: 0 },
            },
            {
                path: "/subSystemResource/scene/toilet/index",
                name: "sceneToilet",
                component: () => import("../views/scene/toilet/index"),
                meta: { title: "厕所", access: 0 },
            },
            {
                path: "/subSystemResource/scene/draughtFan/index",
                name: "draughtFan",
                component: () => import("../views/scene/draughtFan/index"),
                meta: { title: "风机", access: 0 },
            },
            {
                path: "/subSystemResource/scene/airConditioner/index",
                name: "airConditioner",
                component: () => import("../views/scene/airConditioner/index"),
                meta: { title: "空调", access: 0 },
            },
        ],
    },
    {
        // 系统
        path: "/sys",
        component: Layout,
        children: [
            {
                // 系统中心
                path: "/sys/userCenter",
                name: "UserCenter",
                component: () => import("../views/sys/UserCenter"),
                meta: { title: "系统中心", access: 0 },
            },
            {
                // 系统中心-修改密码
                path: "/sys/changePass",
                name: "ChangePass",
                component: () => import("../views/sys/ChangePass"),
                meta: { title: "修改密码", access: 0, affix: true },
            },
            {
                // 系统中心-个人中心
                path: "/sys/userInfo",
                name: "userInfo",
                component: () => import("../views/sys/UserInfo"),
                meta: { title: "订单报表", access: 0, affix: true },
            },
        ],
    },
    {
        //404页面
        path: "/404",
        name: "NotFound",
        meta: {
            title: "Page not found",
            isLogin: false,
        },
        component: () => import("@/views/NotFound"),
    },
    // 所有未定义路由，全部重定向到404页
    {
        path: "*",
        redirect: "/404",
    },
];

const router = new VueRouter({
    mode: "history",
    // base: process.env.BASE_URL + 'vue/',
    base: process.env.BASE_URL,
    // base:'/vue/',
    routes,
});

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location) {
    return originalPush.call(this, location).catch((err) => err);
};
export default router;
